package com.aixin.project.service.gensee;

import com.aixin.project.data.Course;
import com.aixin.project.util.DateUtil;
import com.gensee.ws.castmaker.LoginUser;
import com.gensee.ws.siteadmin.*;
import org.apache.commons.lang.StringUtils;

/**
 * Created by IntelliJ IDEA.
 * User: Sufeng
 * Date: 12-5-6
 * Time: 下午2:31
 * To change this template use File | Settings | File Templates.
 */
public class GenseeService {
    static SaService ss = null;
    static LoginUser user = null;

    static {
        SaService_Service sss = new SaService_Service();
        ss = sss.getSaWebServicePort();
        user = new LoginUser();
        user.setLoginName("admin@91class.com");
        user.setPassword("91class");
        user.setSite("91class.gensee.com");
    }

    public static WebcastCreationResult createLession(Course course) {
        WebcastCreation webcast = new WebcastCreation();
        webcast.setSubject(course.getTitle());
        webcast.setStartTime(DateUtil.convertToXMLGregorianCalendar(course.getStarttime()));
        webcast.setDescription(course.getDescription());
        webcast.setSpeakerInfo(course.getExpertname() + " : " + course.getExpertdes());
        webcast.setPlan(""); //richeng anpai
        webcast.setLoginRequired(false);
        webcast.setOpened(false);
        webcast.setSwitchClient(false);
        webcast.setHasVideo(true);
        webcast.setVideoFps(20);
        webcast.setVideoLevel(20);
        webcast.setOrganizerToken(StringUtils.trimToNull(course.getZzzpass()));     //zuzhizhe password
        webcast.setPanelistToken(StringUtils.trimToNull(course.getJbpass()));      //jiabin password
        webcast.setAttendeeToken(StringUtils.trimToNull(course.getCyzpass()));      //canjiazhe password
        return ss.createWebcast(user, webcast);
    }

    public static void main(String[] args) {
        OngoingWebcastPaginationResult ret = ss.pageOngoingWebcasts(user, 1, 4);
        System.out.println(ret.getWebcast().size());

        WebcastCreation webcast = new WebcastCreation();
        webcast.setSubject("webserivce-test lession-01");
        webcast.setDescription("webservice-test lession description");
        webcast.setLoginRequired(false);
        webcast.setOpened(false);
        webcast.setPlan("plan");
        webcast.setStartTime(DateUtil.convertToXMLGregorianCalendar(DateUtil.strToDate("2012-05-20 15:50:50")));
        webcast.setHasVideo(true);
        webcast.setOrganizerToken("111111");
        webcast.setPanelistToken("222222");
        webcast.setAttendeeToken("333333");
        webcast.setSpeakerInfo("SpeakerInfo");
        webcast.setSwitchClient(false);
        webcast.setVideoFps(20);
        webcast.setVideoLevel(20);


//        webcast.setTime(DateUtil.convertToXMLGregorianCalendar(DateUtil.strToDate("2012-05-20 15:50:50")));
        WebcastCreationResult result = ss.createWebcast(user, webcast);
        System.out.println(result.getMessage());
        System.out.println(result.getId());

        System.out.println(result.getOrganizerJoinUrl());
        System.out.println(result.getAttendeeJoinUrl());
        System.out.println(result.getPanelistJoinUrl());

    }

}
